﻿#ifndef _ArchiveFactory_H__
#define _ArchiveFactory_H__

#include "kernel/OgreArchive.h"

namespace FD
{
	namespace Kernel
	{
		///<summary> Abstract factory class, archive codec plugins can register concrete
		///subclasses of this.
		///@remarks
		///All access to 'archives' (collections of files, compressed or
		///just folders, maybe even remote) is managed via the abstract
		///Archive class. Plugins are expected to provide the
		///implementation for the actual codec itself, but because a
		///subclass of Archive has to be created for every archive, a
		///factory class is required to create the appropriate subclass.
		///@par
		///So archive plugins create a subclass of Archive AND a subclass
		///of ArchiveFactory which creates instances of the Archive
		///subclass. See the 'Zip' and 'FileSystem' plugins for examples.
		///Each Archive and ArchiveFactory subclass pair deal with a
		///single archive type (identified by a string).
		/// </summary>
		class FD_Kernel_Export ArchiveFactory : public FD::Kernel::CReferenced
		{
		public:
			virtual ~ArchiveFactory();
			ArchiveFactory();

			virtual String getType(void) const;
			/// <summary> Creates a new object.</summary>
			/// <param>name= "name" Name of the object to create</param>
			/// <returns>return An object created by the factory. The type of the object depends on
			///the factory.</returns>

			//virtual FD::Kernel::Archive *createInstance( const String &name );
			virtual Archive* createInstance(const String& name, bool readOnly);

			virtual Archive* createInstance(const String& name) { return createInstance(name, true); }
			/// <summary> Destroys an object which was created by this factory.</summary>
			/// <param> name  =" ptr" Pointer to the object to destroy </param>
			/// <returns></returns>
			virtual void destroyInstance( FD::Kernel::Archive *ptr);
		};
	}
}

#endif

